<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>社区商品</title>
    <script type="text/javascript" src="__PUBLIC__/V3/layer/layer.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/V1/plugins/layui/css/layui.css" media="all">
    <script src="__PUBLIC__/V1/plugins/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__PUBLIC__/V3/js/jquery-1.7.1.js"></script>
</head>
<body>
<div style="margin-top: 20px">
    <form class="layui-form" id="goods_category_form">
        <input  type="hidden" name="id" value="<?php echo isset($data->id)?$data->id:'0' ?>">
        <input  type="hidden" name="pid" value="{$pid}">
        <input  type="hidden" name="deep" value="{$deep}">
        <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-block">
                <input type="text" name="category_name" required  lay-verify="required" placeholder="请输入分类名称" autocomplete="off" class="layui-input"
                       value="<?php echo isset($data->category_name)?$data->category_name:'' ?>"
                >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" lay-skin="switch" name="status" <?php echo isset($data->status)&&$data->status==0?"checked":"" ?> >
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit_">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form()
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
        form.on('submit(submit_)', function (data) {
            $.ajax({
                url: "{:addon_url('admin://goods/category_operation')}",
                dataType: "json",
                async: true,
                data: $("#goods_category_form").serialize(),
                type: "POST",
                success: function (res)
                {
                    if (res.code == 0)
                    {
                        layer.alert(res.msg, {icon: 1});
                    }
                    else
                    {
                        layer.alert(res.msg, {icon: 5});
                    }
                }
            });
            return false;
        });
    });
</script>